//
//  CZHookInject.m
//  CZHook
//
//  Created by czera on 2020/4/15.
//  Copyright © 2020 czera. All rights reserved.
//

// hook登录用户名、密码

#import "CZHookInject.h"
#import <objc/runtime.h>

@implementation CZHookInject

+(void)load{
    Method oldMyNext = class_getInstanceMethod(objc_getClass("WCAccountMainLoginViewController"), @selector(onNext));
    
    Method newMyNext = class_getInstanceMethod(self, @selector(hook_myNext));
    
    method_exchangeImplementations(oldMyNext, newMyNext);
}

-(void)hook_myNext{
    NSString *userNmaeStr = [[[self valueForKey:@"_textFieldUserNameItem"] valueForKey:@"m_textField"] performSelector:@selector(text)];
    
    NSLog(@"输入的用户名是：%@",userNmaeStr);
    
    /*
     当获取完用户的密码的时候，我们需要代码走之前的逻辑，这时我们需要调用原来的方法，但是怎么调用呢？是调用hook_myNext方法吗？会发生什么呢？
     
     注意：这里如果崩溃，把下面的 `[self hook_myNext];`代码注释即可
     */
    [self hook_myNext];
}

@end
